var baseURL = "../../";
var vx = new Vue({
    el:'#car_setting_app',
    data:{
        url:"/modules/xinpai/car_monitor.html",
        projectList:[],
        buttons:[{name:'实时监控',url:'/modules/xinpai/car_monitor.html'},{name:'轨迹回放',url:null},{name:'视频监控',url:'/modules/xinpai/car_video.html'},{name:'作业轨迹',url:"/modules/xinpai/car_manage.html"},{name:'作业预警',url:null},{name:'日行里程',url:null},{name:'日行油耗',url:null},{name:'每日报表',url:null},{name:'车辆类型',url:null},{name:'司机管理',url:null},{name:'车辆台账',url:null}]
    },
    methods: {
        action:function (url,item) {
            html=`?pid=${item.pid}"&firmId="${item.firmId}`;
            this.url=url||"/modules/xinpai/error.html";
            this.url=this.url+html;
        },
        selectProjectList:function (data={parentId:0,type:0}) {
            console.log("登录");
            $.ajax({
                type: "GET",
                url:  baseURL + 'xinpai/project/list',
                contentType: "application/json",
                data: data,
                success: function(r){
                    if(r.code === 0){
                        if(data.parentId>0){
                            vx.areaList=r.list;
                        }else{
                            vx.projectList=r.list;
                            if(r.list.length>0){
                                vx.url="/modules/xinpai/car_monitor.html?pid="+r.list[0].pid+"&firmId="+r.list[0].firmId;
                            }else{
                                vx.url="/modules/xinpai/error.html"
                            }
                        }
                        vx.$nextTick(function () {
                            $('.collapse').collapse('hide');
                            $("#set"+r.list[0].pid).collapse("show");
                        })
                    }else{
                        alert(r.msg);
                    }
                }
            });
        },
    },
    created:function() {
        this.selectProjectList();
    }

});
//iframe自适应
$(window).on('resize', function() {
    var $content = $('.content-1');
    $content.height($(this).height() + 500);
    $content.find('iframe').each(function() {
        $(this).height($content.height());
    });
}).resize();